#pragma once

#include <QtWidgets/QWidget>
#include "ui_CCMainWindow.h"
#include "BasicWindow.h"
#include <QPixmap>
#include <QProxyStyle>
#include <QStyle>
#include <QHBoxLayout>
#include "SkinWidget.h"
#include <QTimer>
#include "SysTray.h"
#include <QTreeWidgetItem>
#include <QTreeWidget>
#include "RootcontactItem.h"
#include "ContactItem.h"
#include <QMap>
#include <TalkWindowShell.h>
class WindowManager;
#include <QApplication>
#include <QMouseEvent>

extern QString  userA;

//face_setting_btn_normal.png
enum APP_NAME {
	app_1 = 0,
	app_2,
	app_3,
	app_4,
	app_5,
	app_6,
	app_7,
	app_8,
	app_9,
	app_10,
	app_11,
	skin,
	face_setting_btn_normal
};

QT_BEGIN_NAMESPACE
namespace Ui { class CCMainWindowClass; };
QT_END_NAMESPACE

class CCMainWindow : public BasicWindow
{
    Q_OBJECT

public:
    CCMainWindow(QWidget *parent = nullptr);
    ~CCMainWindow();

public:
	void setUserName(const QString &username);
	void setLevelPixmap(int level);
	void setStatusMenuIcon(const QString &path);
	void setHeadPixmap(const QString &path);
	QWidget* addOtherAppExtension(const QString &appPath, APP_NAME appName);

public:
	virtual bool eventFilter(QObject *watched, QEvent *event)override;

protected:
	virtual void resizeEvent(QResizeEvent *event)override;
	virtual void mousePressEvent(QMouseEvent *event)override;

private slots:
	//void onShowMin();
	//void onShowClose();
	void onSkinAppIconClicked();

	void onItemClicked(QTreeWidgetItem *item, int column);
	void onItemDoubleClicked(QTreeWidgetItem *item, int column);

	void onItemExpanded(QTreeWidgetItem *item);
	void onItemCollapsed(QTreeWidgetItem *item);

	void onShowQuit(bool);

private:
    Ui::CCMainWindowClass *ui;

	void initTimer();
	void initControl();
	void initContactTree();

	void addCompanyDeps(QTreeWidgetItem *pRootGroupItem, const int &sDeps);

	QMap< QTreeWidgetItem*, int> m_groupMap;


};

//
//class CustomProxyStyle : public QProxyStyle
//{
//public:
//	virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
//		const QWidget *w = nullptr) const override
//	{
//		if (pe == QStyle::PE_FrameFocusRect) {
//			return;
//		}
//		else {
//			return QProxyStyle::drawPrimitive(pe, opt, p, w);
//		}
//	}
//};